package cn.wokoba.service.activity.service.state;


import cn.wokoba.service.activity.model.ActivityStateVO;
import cn.wokoba.service.activity.model.RaffleActivityStageEntity;
import cn.wokoba.service.activity.repository.ActivityRepository;
import cn.wokoba.service.activity.service.state.handler.ActivityStateHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//抽奖活动上架服务
@Service
public class RaffleActivityStageService {

    @Autowired
    private ActivityRepository repository;
    @Autowired
    ActivityStateHandler activityStateHandler;

    public void appendStageActivity(String channel, String source, Long activityId) {
        repository.appendStageActivity(channel, source, activityId);
    }


    public Long queryStageActivityId(String channel, String source) {
        return repository.queryStageActiveBySC(channel, source);
    }

    public List<RaffleActivityStageEntity> queryStageActivityList() {
        return repository.queryStageActivityList();
    }

    public Long queryStageActivity2ActiveById(Long id) {
        return repository.queryStageActivity2ActiveById(id);
    }


    public void updateStageActivity2Active(Long activityId) {
        String currActivityState = repository.queryCurrActivityState(activityId);
        activityStateHandler.open(activityId, ActivityStateVO.valueOf(currActivityState));
    }
}
